package cn.tedu.jdbc;

import java.sql.Connection;
import java.sql.Statement;
import java.util.Scanner;

public class JDBCDemo04 {
    public static void main(String[] args) {
        try {
            Connection connection=DBUtil.getConnection();
            Statement statement = connection.createStatement();
            Scanner scanner=new Scanner(System.in);
            System.out.println("请输入用户名");
            String username=scanner.nextLine();
            int i = statement.executeUpdate("DELETE FROM userinfo WHERE username='" + username + "'");
            if (i > 0){
                System.out.println("删除成功！");
            }else {
                System.out.println("删除失败！");
            }
            connection.close();
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
